<?php

class LoginView{
	private $username = "username";
	private $password = "password";
	private $loginbutton = "loginbutton";
	private $logoutbutton = "logoutbutton";
	
	private $SubmitButtonValue = "Login";
	private $LogoutButtonValue = "Logout";
	//Skriver ut en "Login" knapp
	public function DoLoginBox() {
		return "<div><form method=\"post\" >
		Username: <input type=\"text\" name=\"username\" /></br>
		Password: <input type=\"password\" name=\"password\" /></br>
		<input type=\"submit\" value=\"$this->SubmitButtonValue\" name=\"loginbutton\" />
		<input type=\"checkbox\" name=\"remember\" value=\"$this->LogoutButtonValue\" /> Remember me </form></div>";
	}
	//Skriver ut en "Logout" knapp
	public function DoLogoutBox() {
		return "<div><form method =\"post\"><input type=\"submit\" value=\"Logout\" name=\"logoutbutton\"/></form></div>";
	}
	//Hämtar användarens användarnamn ifrån textrutan "username"
	public function GetUserName() {
		return (trim($_POST[$this->username]) != "" ? $_POST[$this->username] : NULL);
	}
	//Hämtar användarens lösenord ifrån textrutan "password"
	public function GetPassword() {
		return (trim($_POST[$this->password]) != ""  ? $_POST[$this->password] : NULL);
	}
	//Ser om användaren klickat på "login" knappen
	public function TriedToLogIn() {
		return (isset($_POST[$this->loginbutton]) && $_POST[$this->loginbutton] == $this->SubmitButtonValue);
	}
	//Ser om användaren klickat på "logout" knappen
	public function TriedToLogOut() {
		return (isset($_POST[$this->logoutbutton]) && $_POST[$this->logoutbutton] == $this->LogoutButtonValue);
	}
}

?>
